package com.foreknow.service.impl;

import com.foreknow.dao.impl.CartDaoImpl;
import com.foreknow.db.DBManager;
import com.foreknow.model.Cart;
import com.foreknow.service.CartService;

import java.sql.Connection;
import java.util.List;

public class CartServiceImpl implements CartService {
    @Override
    public List<Object> listCart(Cart cart) {
        DBManager dbManager = DBManager.getInstance();
        Connection conn = dbManager.getConnection();
        CartDaoImpl cartDao = new CartDaoImpl();
        //注入数据库的连接
        cartDao.setConnection(conn);
        return cartDao.listCart(cart);
    }

    public static void main(String[] args) {
        CartService service = new CartServiceImpl();
        Cart cart = new Cart();
        cart.setUserId("8080");
        cart.setBusinessId(10001);
        List<Object> list = service.listCart(cart);
        System.out.println(list);
    }
}
